getwd()
ComDir <- "/Users/luiscubillos/ADMwork/MOSAR/FishStock/ComdsR/Envi.R"
source(ComDir)
ComDir <- "/Users/luiscubillos/ADMwork/MOSAR/FishStock/ComdsR/mis_tools.R"
source(ComDir)

#if sardine
sOutDir <-"/Users/luiscubillos/ADMwork/MOSAR/FishStock/Sben" 
setwd(sOutDir)
#if anchovy
aOutDir <-"/Users/luiscubillos/ADMwork/MOSAR/FishStock/Erin" 
setwd(aOutDir)
rm(Sben)
list.files()
  
#lee el reporte

Sben <- read.myout('sben2010')
names(Sben)
yrs<-seq(1992,2010,1)
yr <-c(1:228)

plot(Sben$s_cpue,type="l",col=2)
lines(Sben$s_pred_cpue,type="l",col=1)
plot(log(Sben$s_obs_catch/Sben$s_pred_catch),type="l",col=2)
lines(log(Sben$s_pred_catch),type="l",col=1)
plot(Sben$ssb[-1],Sben$rt,type="b",xlim=c(0,1.1*max(Sben$ssb)))
plot(yr,Sben$btot,type="l",col=1,ylim=c(0,5e6))
lines(yr,Sben$vulnb)
lines(yr,Sben$sbiom,type="l",col=1)
points(yr,Sben$s_pred_SSB)
points(yr,Sben$s_obs_Brec,pch=19,col=1)
points(yr,Sben$s_obs_Bpel,pch=19,col=6)
N <- matrix(Sben$N,228,22,byrow=T)
matplot(yr,N[,],type="l")
plot(Sben$ft,type="l")
plot(yrs,Sben$ssb,type="b",col=3)
lines(Erin$ssb,type="b",col=4)
plot(yrs[-1],Sben$rt,type="b",col=3)
W <- matrix(Sben$s_weico,228,22,byrow=T)
matplot(yr,W[,],type="l")
L <- matrix(Sben$s_lenco,228,22,byrow=T)
matplot(yr,L[,],type="l")
Ws <-0.0009*L^3
matplot(yr,Ws[,],type="l")
Ns <- Ws*N
matplot(yr,Ns[,],type="l")
b<-rep(NA,228)
dim(b)
for(i in 1:228){b[i] <- sum(N[i,])}
plot(yr,b,type="l")

plot(Sben$ssb[-1],Sben$rt,type="b",ylim=c(0,5e5))
Sben$q
Sben$tau
Sben$sig

rm(Erin)
Erin <- read.myout('erin2010')
yr <-c(1:228)
names(Erin)
plot(Erin$s_cpue,type="l",col=2)
lines(Erin$s_pred_cpue,type="l",col=1)
plot(yr,Erin$btot,type="l",col=1,ylim=c(0,1.1*max(Erin$btot)))
lines(Erin$sbiom,type="l",col=1)
lines(Erin$vulnbiom,type="l",col=1)
points(Erin$s_obs_Bpel,pch=19,col=4)
lines(Erin$s_pred_Bpel,col=4)
plot(Erin$ssb[-1],Erin$rt,xlim=c(0,1.1*max(Erin$ssb)))
plot(Erin$ft,type="l")
plot(Erin$ssb,type="l")
plot(Erin$rt,type="b")
Erin$sig
er.p<-read.fit('erin2010')
names(er.p)
er.p$est

###################
list.files()
mc <- read.myout("mcvok")
names(mc)
mc$year
plot(mc$TotalBiomass,type="l",ylim=c(0,1.1*max(mc$TotalBiomass)))
lines(mc$SSB,col=2)

